package com.wangshang.statistic.dao;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wangshang.statistic.po.Statistics;

/**
 * A data access object (DAO) providing persistence and search support for
 * Statistics entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.wangshang.statistic.po.Statistics
 * @author MyEclipse Persistence Tools
 */

public class StatisticsDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(StatisticsDAO.class);
	// property constants
	public static final String AFTER_SELL_R = "afterSellR";
	public static final String AFTER_SELL_W = "afterSellW";
	public static final String COMMODITIES_R = "commoditiesR";
	public static final String COMMODITIES_W = "commoditiesW";
	public static final String COMMODITY_KINDS_R = "commodityKindsR";
	public static final String COMMODITY_KINDS_W = "commodityKindsW";
	public static final String FEEDBACK_TEAM_SHOP_R = "feedbackTeamShopR";
	public static final String FEEDBACK_TEAM_SHOP_W = "feedbackTeamShopW";
	public static final String HALLS_R = "hallsR";
	public static final String HALLS_W = "hallsW";
	public static final String LOCATION_R = "locationR";
	public static final String LOCATION_W = "locationW";
	public static final String MY_FAVES_R = "myFavesR";
	public static final String MY_FAVES_W = "myFavesW";
	public static final String ORDER_COMMODITIES_R = "orderCommoditiesR";
	public static final String ORDER_COMMODITIES_W = "orderCommoditiesW";
	public static final String PRICE_TABLE_R = "priceTableR";
	public static final String PRICE_TABLE_W = "priceTableW";
	public static final String SERVICE_DESPAIR_R = "serviceDespairR";
	public static final String SERVICE_DESPAIR_W = "serviceDespairW";
	public static final String SERVICE_GOOD_R = "serviceGoodR";
	public static final String SERVICE_GOOD_W = "serviceGoodW";
	public static final String SERVICES_R = "servicesR";
	public static final String SERVICES_W = "servicesW";
	public static final String SHOP_ORDER_R = "shopOrderR";
	public static final String SHOP_ORDER_W = "shopOrderW";
	public static final String TEAM_SHOP_INFO_R = "teamShopInfoR";
	public static final String TEAM_SHOP_INFO_W = "teamShopInfoW";
	public static final String TEAM_SHOPPING_R = "teamShoppingR";
	public static final String TEAM_SHOPPING_W = "teamShoppingW";
	public static final String USER_R = "userR";
	public static final String USER_W = "userW";
	public static final String WORKER_R = "workerR";
	public static final String WORK_W = "workW";

	protected void initDao() {
		// do nothing
	}

	public void save(Statistics transientInstance) {
		log.debug("saving Statistics instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Statistics persistentInstance) {
		log.debug("deleting Statistics instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Statistics findById(java.util.Date id) {
		log.debug("getting Statistics instance with id: " + id);
		try {
			Statistics instance = (Statistics) getHibernateTemplate().get(
					"com.wangshang.statistic.Statistics", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Statistics instance) {
		log.debug("finding Statistics instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Statistics instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Statistics as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByAfterSellR(Object afterSellR) {
		return findByProperty(AFTER_SELL_R, afterSellR);
	}

	public List findByAfterSellW(Object afterSellW) {
		return findByProperty(AFTER_SELL_W, afterSellW);
	}

	public List findByCommoditiesR(Object commoditiesR) {
		return findByProperty(COMMODITIES_R, commoditiesR);
	}

	public List findByCommoditiesW(Object commoditiesW) {
		return findByProperty(COMMODITIES_W, commoditiesW);
	}

	public List findByCommodityKindsR(Object commodityKindsR) {
		return findByProperty(COMMODITY_KINDS_R, commodityKindsR);
	}

	public List findByCommodityKindsW(Object commodityKindsW) {
		return findByProperty(COMMODITY_KINDS_W, commodityKindsW);
	}

	public List findByFeedbackTeamShopR(Object feedbackTeamShopR) {
		return findByProperty(FEEDBACK_TEAM_SHOP_R, feedbackTeamShopR);
	}

	public List findByFeedbackTeamShopW(Object feedbackTeamShopW) {
		return findByProperty(FEEDBACK_TEAM_SHOP_W, feedbackTeamShopW);
	}

	public List findByHallsR(Object hallsR) {
		return findByProperty(HALLS_R, hallsR);
	}

	public List findByHallsW(Object hallsW) {
		return findByProperty(HALLS_W, hallsW);
	}

	public List findByLocationR(Object locationR) {
		return findByProperty(LOCATION_R, locationR);
	}

	public List findByLocationW(Object locationW) {
		return findByProperty(LOCATION_W, locationW);
	}

	public List findByMyFavesR(Object myFavesR) {
		return findByProperty(MY_FAVES_R, myFavesR);
	}

	public List findByMyFavesW(Object myFavesW) {
		return findByProperty(MY_FAVES_W, myFavesW);
	}

	public List findByOrderCommoditiesR(Object orderCommoditiesR) {
		return findByProperty(ORDER_COMMODITIES_R, orderCommoditiesR);
	}

	public List findByOrderCommoditiesW(Object orderCommoditiesW) {
		return findByProperty(ORDER_COMMODITIES_W, orderCommoditiesW);
	}

	public List findByPriceTableR(Object priceTableR) {
		return findByProperty(PRICE_TABLE_R, priceTableR);
	}

	public List findByPriceTableW(Object priceTableW) {
		return findByProperty(PRICE_TABLE_W, priceTableW);
	}

	public List findByServiceDespairR(Object serviceDespairR) {
		return findByProperty(SERVICE_DESPAIR_R, serviceDespairR);
	}

	public List findByServiceDespairW(Object serviceDespairW) {
		return findByProperty(SERVICE_DESPAIR_W, serviceDespairW);
	}

	public List findByServiceGoodR(Object serviceGoodR) {
		return findByProperty(SERVICE_GOOD_R, serviceGoodR);
	}

	public List findByServiceGoodW(Object serviceGoodW) {
		return findByProperty(SERVICE_GOOD_W, serviceGoodW);
	}

	public List findByServicesR(Object servicesR) {
		return findByProperty(SERVICES_R, servicesR);
	}

	public List findByServicesW(Object servicesW) {
		return findByProperty(SERVICES_W, servicesW);
	}

	public List findByShopOrderR(Object shopOrderR) {
		return findByProperty(SHOP_ORDER_R, shopOrderR);
	}

	public List findByShopOrderW(Object shopOrderW) {
		return findByProperty(SHOP_ORDER_W, shopOrderW);
	}

	public List findByTeamShopInfoR(Object teamShopInfoR) {
		return findByProperty(TEAM_SHOP_INFO_R, teamShopInfoR);
	}

	public List findByTeamShopInfoW(Object teamShopInfoW) {
		return findByProperty(TEAM_SHOP_INFO_W, teamShopInfoW);
	}

	public List findByTeamShoppingR(Object teamShoppingR) {
		return findByProperty(TEAM_SHOPPING_R, teamShoppingR);
	}

	public List findByTeamShoppingW(Object teamShoppingW) {
		return findByProperty(TEAM_SHOPPING_W, teamShoppingW);
	}

	public List findByUserR(Object userR) {
		return findByProperty(USER_R, userR);
	}

	public List findByUserW(Object userW) {
		return findByProperty(USER_W, userW);
	}

	public List findByWorkerR(Object workerR) {
		return findByProperty(WORKER_R, workerR);
	}

	public List findByWorkW(Object workW) {
		return findByProperty(WORK_W, workW);
	}

	public List findAll() {
		log.debug("finding all Statistics instances");
		try {
			String queryString = "from Statistics";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Statistics merge(Statistics detachedInstance) {
		log.debug("merging Statistics instance");
		try {
			Statistics result = (Statistics) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Statistics instance) {
		log.debug("attaching dirty Statistics instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Statistics instance) {
		log.debug("attaching clean Statistics instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static StatisticsDAO getFromApplicationContext(ApplicationContext ctx) {
		return (StatisticsDAO) ctx.getBean("StatisticsDAO");
	}
}